package View;
import java.awt.BorderLayout;
import java.awt.GridBagLayout;

import javax.swing.JPanel;
import javax.swing.JLabel;

import java.awt.Rectangle;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.JTextArea;
import javax.swing.JComboBox;
import java.awt.Font;



public class ConfigurationView extends JFrame {

	private JLabel ipLabel = null;
	private JTextField ipField = null;
	
	private JTextField portField = null;
	private JLabel portLabel = null;
	
	private JLabel dbpasswordLabel = null ;
	private JTextField dbpasswordField = null;
	
	private JLabel userNameLabel = null ;
	private JTextField userNameField = null;
	
	private JButton okButton;
	private JButton exitButton;
	
	/**
	 * This is the default constructor
	 */
	
	public ConfigurationView() {
		super();
		initialize();
	}

	/**
	 * This method initializes StudentForm
	 */
	
	private void initialize() {
		
		ipLabel = new JLabel();
		ipLabel.setFont(new Font("Tahoma", Font.PLAIN, 13));
		ipLabel.setBounds(new Rectangle(20, 88, 113, 19));
		ipLabel.setText("Ip :");
		
		ipField = new JTextField(16);
		ipField.setBounds(new Rectangle(143, 89, 127, 17));
		
		portLabel = new JLabel();
		portLabel.setFont(new Font("Tahoma", Font.PLAIN, 13));
		portLabel.setBounds(new Rectangle(20, 113, 113, 18));
		portLabel.setText("Port :");
		
		portField = new JTextField(10);
		portField.setBounds(new Rectangle(143, 114, 127, 18));

		dbpasswordLabel = new JLabel();
		dbpasswordLabel.setFont(new Font("Tahoma", Font.PLAIN, 13));
		dbpasswordLabel.setBounds(new Rectangle(20, 31, 113, 17));
		dbpasswordLabel.setText("Password :");
		
		dbpasswordField = new JTextField(20);		
		dbpasswordField.setBounds(new Rectangle(143, 31, 127, 17));
		
		userNameLabel = new JLabel();
		userNameLabel.setFont(new Font("Tahoma", Font.PLAIN, 13));
		userNameLabel.setBounds(new Rectangle(20, 59, 113, 18));
		userNameLabel.setText("User Name :");
		
		userNameField = new JTextField(20);		
		userNameField.setBounds(new Rectangle(143, 61, 127, 17));
		
		okButton = new JButton("Connect");
		okButton.setFont(new Font("Tahoma", Font.BOLD, 13));
		exitButton = new JButton("Exit");
		exitButton.setFont(new Font("Tahoma", Font.BOLD, 13));
		okButton.setBounds(79, 155, 100, 30);
		exitButton.setBounds(211, 155, 100, 30);
		
		userNameField.setText("root");
		dbpasswordField.setText("1234");
		ipField.setText("localhost");
		portField.setText("5555");

		this.setSize(372, 240);
	    this.setResizable(false);
	    this.setTitle("Configuration");
		getContentPane().setLayout(null);
		getContentPane().add(ipLabel, null);
		getContentPane().add(ipField, null);
		getContentPane().add(portLabel, null);
		getContentPane().add(portField, null);
		getContentPane().add(dbpasswordLabel, null);
		getContentPane().add(dbpasswordField, null);
		
		getContentPane().add(userNameLabel, null);
		getContentPane().add(userNameField, null);
		
		getContentPane().add(okButton, null);
		getContentPane().add(exitButton, null);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
	
	}
	
	
	/**
	 * @param actionListener
	 */
	public void addConfigListeners(ActionListener actionListener){
		okButton.addActionListener(actionListener);
		exitButton.addActionListener(actionListener);
	}
	
	/**
	 * @return
	 */
	public JTextField getIpField() {
		return ipField;
	}
	/**
	 * @return
	 */
	public JLabel getIpLabel() {
		return ipLabel;
	}
	/**
	 * @return
	 */
	public JTextField getPortField() {
		return portField;
	}
	/**
	 * @return
	 */
	public JLabel getPortLabel() {
		return portLabel;
	}
	/**
	 * @return
	 */
	public JTextField getDbpasswordField() {
		return dbpasswordField;
	}
	/**
	 * @return
	 */
	public JLabel getDbpasswordLabel() {
		return dbpasswordLabel;
	}
	
	/**
	 * @return
	 */
	public JButton getOkButton() {
		return okButton;
	}
	
	/**
	 * @return
	 */
	public JButton getExitButton() {
		return exitButton;
	}
	
	// show config window 
	/**
	 * 
	 */
	public void showWindow(){
		setVisible(true);
	}
	
	// Hides config window 
	/**
	 * 
	 */
	public void hideWindow(){
		setVisible(false);
	}

/**
 * @return
 */
public JTextField getUserNameField() {
	return userNameField;
}
}



